package thread;

public class CachePadding {
    private static class T {
        public volatile long x = 0L;
    }

    public static T[] array = new T[2];

    static {
        array[0] = new T();
        array[1] = new T();
    }

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            for (long i = 0; i < 1000_0000L; i++) {
                array[0].x = i;
            }
        });

        Thread t2 = new Thread(() -> {
            for (long i = 0; i < 1000_0000L; i++) {
                array[1].x = i;
            }
        });

        final long start = System.nanoTime();

        t1.start();
        t2.start();
        t1.join();
        t2.join();

        System.out.println((System.nanoTime() - start) / 100_0000);
    }
}
